package com.goods.controller.business;

import com.goods.business.service.IHealthService;
import com.goods.common.response.ResponseBean;
import com.goods.common.vo.business.HealthVO;
import com.goods.common.vo.system.PageVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created with IntelliJ IDEA
 *
 * @Date: 2023/3/7 - 17:21
 * @Author: Hyoung
 * @Description: 9/business/health/history?pageSize=4&pageNum=1
 * Request Method: GET
 */
@RestController
@RequestMapping("/business/health")
public class HealthController {


    @Autowired
    private IHealthService iHealthService;

    @GetMapping("/history")
    public ResponseBean history(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                @RequestParam(value = "pageSize") Integer pageSize,
                                @RequestHeader("Authorization") String authorization) {
        PageVO<HealthVO> pageVO = iHealthService.history(pageNum, pageSize, authorization);
        return ResponseBean.success(pageVO);
    }


    @GetMapping("/isReport")
    public ResponseBean isReport(@RequestHeader("Authorization") String authorization) {

        HealthVO isReport = iHealthService.isReport(authorization);

        return ResponseBean.success(isReport);

    }

    @PostMapping("/report")
    public ResponseBean report(@RequestBody HealthVO healthVO
            , @RequestHeader("Authorization") String authorization) {
        iHealthService.report(healthVO, authorization);
        return ResponseBean.success();
    }

}
